@extends('layouts.public')

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <style>
        .mask{
            position: fixed;
            top:0;
            left:0;
            width:100%;
            height:100vh;
            background: rgba(0,0,0,0.75);
            z-index:1300;
            display: none;
        }
        .content{
            width:250px;
            height:130px;
            background: #fff;
            padding:20px;
            position:absolute;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
            z-index:1301;
            border-radius: 5px;
        }
        .item{
            margin: 10px 0;
        }
    </style>
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="{{route('admin.sale.sales')}}">分销列表</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <form role="form" class="form-inline" method="get">
                            <div class="form-group">
                                <label class="sr-only">活动主题</label>
                                <input type="text" name="title" placeholder="请输入活动主题" class="form-control" value="{{request('title')}}">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">用户名</label>
                                <input type="text" name="nickname" placeholder="请输入用户名" class="form-control" value="{{request('nickname')}}">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">一级分销</label>
                                <input type="text" name="invitor1_nickname" placeholder="请输入一级分销" class="form-control" value="{{request('invitor1_nickname')}}">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">二级分销</label>
                                <input type="text" name="invitor2_nickname" placeholder="请输入二级分销" class="form-control" value="{{request('invitor2_nickname')}}">
                            </div>
                            &nbsp;&nbsp;
                            <div class="form-group">
                                <input placeholder="请选择创建时间范围" class="form-control" id="created_at" type="text" name="created_at" value="{{request('created_at')}}" style="width: 200px;"
                                       autocomplete="off">
                            </div>
                            <button type="submit" class="btn btn-primary">搜索</button>
                            <button type="button" class="btn btn-white" onclick="location.href='{{route('admin.sale.sales')}}'">重置</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr role="row">
                                <th>分销ID</th>
                                <th>活动主题</th>
                                <th>用户</th>
                                <th>佣金</th>
                                <th>一级分销</th>
                                <th>二级分销</th>
                                <th>状态</th>
                                <th class="sorting" orderby="created_at">创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            @foreach($sales as $user)
                                <tr class="gradeA">
                                    <td>{{$user['id']}}</td>

                                    <td>{{$user['title']}}</td>
                                    <td><span><img src="{{$user['avatar']}}" alt=""></span>
                                      {{$user['nickname']}}</td>

                                    <td>{{$user['money']}}</td>
                                    <td><span><img src="{{$user['invitor1']}}" alt=""></span>{{$user['invitor1_nickname']}}</td>
                                    <td><span>@if(isset($user['invitor2']))<img src="{{$user['invitor2']->avatar}}" alt=""></span>@endif{{$user['invitor2_nickname']}}</td>
                                    <td>@if($user['status']==2)
                                        <span style="color:red">禁用</span>
                                        @endif
                                        @if($user['status']==1)
                                            <span style="color:green">激活</span>
                                        @endif
                                    </td>
                                    <td>{{$user['created_at']}}</td>
                                   
                                    <td>
                                        @if($user['status']==2)
                                            <a class="ajaxBtn" href="javascript:void(0);" uri="{{route('admin.sale.sales.changesale',[$user->id])}}" msg="是否激活该分销人员？">激活</a>|
                                        @endif

                                        @if($user['status']!=2)
                                            <a class="ajaxBtn" href="javascript:void(0);" uri="{{route('admin.sale.sales.changesale',[$user->id])}}" msg="是否禁用该分销人员？">禁用</a>|
                                        @endif
                                       
                                    </td>
                                </tr>
                            @endforeach
                        </table>
                        <div class="row">
                            <div class="col-sm-12">
                                <div>共 {{ $sales->total() }} 条记录</div>
                                {!! $sales->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript" src="{{cdn('js/plugins/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        laydate.render({
            elem: '#created_at',
            range: true,
            max: 0
        });
        

    </script>
@endsection
